package com.todo.user.infrastructure.convert;


import com.todo.user.infrastructure.entity.domain.UserAccountDO;
import com.todo.user.infrastructure.entity.po.UserAccountPO;
import com.todo.user.infrastructure.entity.po.UserTravelInfoPO;

/**
 * @author zhangwenxiang
 * @date 2024/3/30 00:06
 * @description
 */
public class UserAccountConvert {
    public static UserAccountDO convertToUserAccountDO(UserAccountPO userAccountPO, UserTravelInfoPO userTravelInfoPO) {
        if (userAccountPO == null) {
            return null;
        }
        UserAccountDO userAccountDO = new UserAccountDO();
        userAccountDO.setId(userAccountPO.getId());
        userAccountDO.setIsDelete(userAccountPO.getIsDelete());
        userAccountDO.setCreateTime(userAccountPO.getCreateTime());
        userAccountDO.setUpdateTime(userAccountPO.getUpdateTime());
        userAccountDO.setBaseAccountInfo(buildBaseAccountInfo(userAccountPO));
        userAccountDO.setAccountDetail(buildAccountDetail(userTravelInfoPO));
        return userAccountDO;
    }

    private static UserAccountDO.AccountDetail buildAccountDetail(UserTravelInfoPO userTravelInfoPO) {
        if (userTravelInfoPO == null) {
            return null;
        }
        UserAccountDO.AccountDetail accountDetail = new UserAccountDO.AccountDetail();
        accountDetail.setMbit(userTravelInfoPO.getMbit());
        accountDetail.setHolidayType(userTravelInfoPO.getHolidayType());
        accountDetail.setTravelPlanType(userTravelInfoPO.getTravelPlanType());
        accountDetail.setTravelObjective(userTravelInfoPO.getTravelObjective());
        accountDetail.setPromotion(userTravelInfoPO.getPromotion());
        accountDetail.setExtra(userTravelInfoPO.getExtra());
        return accountDetail;
    }

    private static UserAccountDO.BaseAccountInfo buildBaseAccountInfo(UserAccountPO userAccountPO) {
        UserAccountDO.BaseAccountInfo baseAccountInfo = new UserAccountDO.BaseAccountInfo();
        baseAccountInfo.setBirthday(userAccountPO.getBirthday());
        baseAccountInfo.setCareer(userAccountPO.getCareer());
        baseAccountInfo.setGender(userAccountPO.getGender());
        baseAccountInfo.setHeadImg(userAccountPO.getHeadImg());
        baseAccountInfo.setBackgroundImg(userAccountPO.getBackgroundImg());
        baseAccountInfo.setIsMobileVerify(userAccountPO.getIsMobileVerify());
        baseAccountInfo.setLocation(userAccountPO.getLocation());
        baseAccountInfo.setMobile(userAccountPO.getMobile());
        baseAccountInfo.setMobileNationCode(userAccountPO.getMobileNationCode());
        baseAccountInfo.setNickName(userAccountPO.getNickName());
        baseAccountInfo.setNativePlace(userAccountPO.getNativePlace());
        baseAccountInfo.setPassword(userAccountPO.getPassword());
        baseAccountInfo.setSignature(userAccountPO.getSignature());
        baseAccountInfo.setSource(userAccountPO.getSource());
        baseAccountInfo.setStatus(userAccountPO.getStatus());
        baseAccountInfo.setUserName(userAccountPO.getUserName());
        baseAccountInfo.setUserType(userAccountPO.getUserType());
        baseAccountInfo.setIsReal(userAccountPO.getIsReal());
        return baseAccountInfo;
    }

    public static UserAccountPO buildUserAccountPO(UserAccountDO userAccountDO) {
        if (userAccountDO == null || userAccountDO.getBaseAccountInfo() == null) {
            return null;
        }
        UserAccountDO.BaseAccountInfo baseAccountInfo = userAccountDO.getBaseAccountInfo();
        UserAccountPO userAccountPO = new UserAccountPO();
        userAccountPO.setId(userAccountDO.getId());
        userAccountPO.setIsReal(baseAccountInfo.getIsReal());
        userAccountPO.setIsMobileVerify(baseAccountInfo.getIsMobileVerify());
        userAccountPO.setMobile(baseAccountInfo.getMobile());
        userAccountPO.setMobileNationCode(baseAccountInfo.getMobileNationCode());
        userAccountPO.setUserName(baseAccountInfo.getUserName());
        userAccountPO.setPassword(baseAccountInfo.getPassword());
        userAccountPO.setNickName(baseAccountInfo.getNickName());
        userAccountPO.setSignature(baseAccountInfo.getSignature());
        userAccountPO.setSource(baseAccountInfo.getSource());
        userAccountPO.setStatus(baseAccountInfo.getStatus());
        userAccountPO.setHeadImg(baseAccountInfo.getHeadImg());
        userAccountPO.setUserType(baseAccountInfo.getUserType());
        userAccountPO.setGender(baseAccountInfo.getGender());
        userAccountPO.setBirthday(baseAccountInfo.getBirthday());
        userAccountPO.setNativePlace(baseAccountInfo.getNativePlace());
        userAccountPO.setLocation(baseAccountInfo.getLocation());
        userAccountPO.setCareer(baseAccountInfo.getCareer());
        userAccountPO.setBackgroundImg(baseAccountInfo.getBackgroundImg());
        userAccountPO.setSource(baseAccountInfo.getSource());
        userAccountPO.setIsDelete(userAccountDO.getIsDelete());
        userAccountPO.setCreateTime(userAccountDO.getCreateTime());
        userAccountPO.setUpdateTime(userAccountDO.getUpdateTime());
        return userAccountPO;
    }

    public static UserTravelInfoPO buildUserTravelInfoPO(UserAccountDO userAccountDO) {
        if (userAccountDO == null || userAccountDO.getAccountDetail() == null) {
            return null;
        }
        UserTravelInfoPO userTravelInfoPO = new UserTravelInfoPO();
        userTravelInfoPO.setMbit(userAccountDO.getAccountDetail().getMbit());
        userTravelInfoPO.setHolidayType(userAccountDO.getAccountDetail().getHolidayType());
        userTravelInfoPO.setTravelPlanType(userAccountDO.getAccountDetail().getTravelPlanType());
        userTravelInfoPO.setTravelObjective(userAccountDO.getAccountDetail().getTravelObjective());
        userTravelInfoPO.setPromotion(userAccountDO.getAccountDetail().getPromotion());
        userTravelInfoPO.setExtra(userAccountDO.getAccountDetail().getExtra());
        userTravelInfoPO.setId(userAccountDO.getId());
        return userTravelInfoPO;
    }
}
